package com.test.cities.page;

import com.test.cities.Exceptions.BusinessException;
import com.test.cities.entity.Stock;
import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.ArrayList;
import java.util.List;

public class Sun {
    public static void main(String[] args) throws BusinessException {
        List<Long> sellList = new ArrayList<>();
        List<Stock> stockList = new ArrayList<>();
        ApplicationContext context = new ClassPathXmlApplicationContext("bean.xml");
        AppleShop appleShop = context.getBean("stockManage", AppleShop.class);

        Stock apple1 = new Stock();
        apple1.setNo(380l);
        apple1.setName("bird");
        apple1.setGood("坏了");
        Stock apple2 = new Stock();
        apple2.setNo(12l);
        apple2.setName("cat");
        apple2.setGood("完好");
        Stock apple3 = new Stock();
        apple3.setNo(10000l);
        apple3.setName("golden");
        apple3.setGood("完好");
        Stock apple4 = new Stock();
        apple4.setNo(36l);
        apple4.setName("cow");
        apple4.setGood("坏了");
        Stock apple5 = new Stock();
        apple5.setName("tree");
        apple5.setGood("完好");
        Stock apple6 = new Stock();
        apple6.setNo(1001l);
        apple6.setName("alibaba");
        apple6.setGood("完好");
        Stock apple7 = new Stock();
        apple7.setNo(20000l);
        apple7.setName("fish");
        apple7.setGood("完好");

        stockList.add(apple1);
        stockList.add(apple2);
        stockList.add(apple3);
        stockList.add(apple4);
        stockList.add(apple5);
        stockList.add(apple6);
        stockList.add(apple7);

        System.out.println("苹果入库stock");
        appleShop.stock(stockList);
        appleShop.sort();

        System.out.println("售出商品sell");
        Long sellNo1 = 12l;
        Long sellNo2 = 1001l;
        Long sellNo3 = 20000l;
        sellList.add(sellNo1);
        sellList.add(sellNo2);
        sellList.add(sellNo3);
        appleShop.sell(sellList);
        appleShop.sort();

        System.out.println("返回箱子return");
        appleShop.returnBox();

        System.out.println("关店移入塑料袋close");
        appleShop.close();
        appleShop.sort();
    }
}
